﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="ActivityUserManage.aspx.cs" Inherits="MobileServer.Web.Admin.ActivityUserManage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="ID" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
        EnableModelValidation="True" Height="50px" Width="125px">
        <Fields>
            <asp:TemplateField HeaderText="ActivityID" SortExpression="ActivityID">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ActivityID") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="SqlDataSource2" DataTextField="Title" DataValueField="ID" 
                        SelectedValue='<%# Bind("ActivityId") %>'>
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("ActivityID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="UserID" SortExpression="UserID">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("UserID") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="Id" 
                        SelectedValue='<%# Bind("UserID") %>'>
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("UserID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="IsEnter" HeaderText="IsEnter" 
                SortExpression="IsEnter" />
            <asp:CheckBoxField DataField="SignIn" HeaderText="SignIn" 
                SortExpression="SignIn" />
            <asp:BoundField DataField="Code" HeaderText="Code" />
            <asp:CheckBoxField DataField="IsSMS" HeaderText="IsSMS" 
                SortExpression="IsSMS" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" DataSourceID="SqlDataSource1" EnableModelValidation="True">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                SortExpression="ID" />
            <asp:TemplateField HeaderText="ActivityID" SortExpression="ActivityID">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="SqlDataSource2" DataTextField="Title" DataValueField="ID" 
                        SelectedValue='<%# Bind("ActivityId", "{0}") %>'>
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="UserID" SortExpression="UserID">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="Id" 
                        SelectedValue='<%# Bind("UserID") %>'>
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="IsEnter" HeaderText="IsEnter" 
                SortExpression="IsEnter" />
            <asp:CheckBoxField DataField="SignIn" HeaderText="SignIn" 
                SortExpression="SignIn" />
            <asp:BoundField DataField="UpdateTime" HeaderText="UpdateTime" ReadOnly="True" 
                SortExpression="UpdateTime" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DefaultDB %>" 
        DeleteCommand="DELETE FROM [Bis_ActivityUser] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [Bis_ActivityUser] ([ActivityID],[UserID], [UserName], [IsEnter], [SignIn], [Code],[IsSms]) VALUES (@ActivityID, @UserID, (select Name from sec_user where Id = @UserID), @IsEnter, @SignIn,@Code,@IsSms)" 
        SelectCommand="SELECT [ActivityID], (select Title from bis_activity where bis_activity.Id=Bis_ActivityUser.ActivityId) as Title, [ID], [UserID], [UserName], [IsEnter], [SignIn], [UpdateTime] FROM [Bis_ActivityUser] ORDER BY UpdateTime DESC" 
        UpdateCommand="UPDATE [Bis_ActivityUser] SET [ActivityID] = @ActivityID, [UserID] = @UserID, [UserName] = (select Name from sec_user where Id = @UserID), [IsEnter] = @IsEnter, [SignIn] = @SignIn WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Object" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ActivityID" />
            <asp:Parameter Name="UserID" />
            <asp:Parameter Name="IsEnter" Type="Boolean" />
            <asp:Parameter Name="SignIn" Type="Boolean" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="ActivityID" />
            <asp:Parameter Name="UserID" />
            <asp:Parameter Name="IsEnter" Type="Boolean" />
            <asp:Parameter Name="SignIn" Type="Boolean" />
            <asp:Parameter Name="ID" Type="Object" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DefaultDB %>" 
        SelectCommand="SELECT [ID], [Title] FROM [Bis_Activity]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DefaultDB %>" 
        SelectCommand="SELECT [Id], [Name] FROM [SEC_User] ORDER BY [NAME]"></asp:SqlDataSource>
</asp:Content>
